<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.io.*"%>
        <%
            int byteRead=0;
            byte[] buff=new byte[1];
			 String url=getServletContext().getRealPath("/")+"Files";
            String fileName=request.getParameter("filename");

            File fileToDownload=new File(url+"\\"+fileName);
            FileInputStream fis=new FileInputStream(fileToDownload);
            BufferedInputStream bis=new BufferedInputStream(fis);

            OutputStream os=response.getOutputStream();
            BufferedOutputStream bos=new BufferedOutputStream(os);

            response.setContentType("application/doc");
            response.setHeader("Content-disposition","attachment;filename="+fileName);

            while((byteRead = bis.read(buff,0,buff.length))!=-1){
                bos.write(buff);
                bos.flush();
                }
        %>
    
   